#使用的编译器

CC = sdcc

#传入的c文件名
TARGET_ARCH = my

C_SOURCES =  \
usr/main.c \


C_INCLUDES =  \
-Iinc \
-Isource \

CFLAGS=$(C_INCLUDES)
cname = my
proj = output
tmpdir = Build
usrdir = usr
all : $(tmpdir)/$(cname).ihx $(tmpdir)/$(cname).hex
OBJECTS = $(addprefix $(tmpdir)/,$(notdir $(C_SOURCES:.c=.rel)))
vpath %.c $(sort $(dir $(C_SOURCES)))
$(tmpdir)/%.rel: %.c Makefile | $(tmpdir) 
	$(CC) -c $(CFLAGS) $< -o $@
$(tmpdir)/$(cname).ihx: $(OBJECTS)
	$(CC) $^ -o $(tmpdir)/$(cname).ihx
$(tmpdir)/%.hex: $(tmpdir)/%.ihx | $(tmpdir)
	packihx $< $@ > $(tmpdir)/$(cname).hex
$(tmpdir):
	mkdir $@
.PHONY : clean
clean :
	rm $(tmpdir)/*.hex
	rm $(tmpdir)/*.rel
	rm $(tmpdir)/*.rst
	rm $(tmpdir)/*.sym
	rm $(tmpdir)/*.mem
	rm $(tmpdir)/*.map
	rm $(tmpdir)/*.lst
	rm $(tmpdir)/*.lk
	rm $(tmpdir)/*.ihx
	rm $(tmpdir)/*.asm
	
